<?php
/**
 * 公共头部文件
 * 相对路径: inc/head.php
 * 作者: 15058593138@qq.com
 */

$isAdmin = isset($_SESSION['is_admin']) && $_SESSION['is_admin'] == 1;
$userPhone = isset($_SESSION['user_phone']) ? $_SESSION['user_phone'] : '';
$currentDo = isset($_GET['do']) ? $_GET['do'] : '';

// 获取当前用户类型的菜单
$menus = $isAdmin ? $MENUS['admin'] : $MENUS['user'];
$pagePrefix = $isAdmin ? 'admin.php' : 'index.php';
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>教室座位预定系统</title>
    <link rel="stylesheet" href="./inc/pubs.css?v=D<?php echo VERSION; ?>">
</head>
<body>
    <div class="header">
        <h1>教室座位预定系统</h1>
        <div>
            <span style="margin-right:15px;">欢迎，<?php echo $userPhone; ?></span>
            <a href="<?php echo $pagePrefix; ?>?do=lgout" class="btn btn-secondary btn-sm">退出</a>
        </div>
    </div>
    
    <div class="container">
        <nav class="navbar">
            <?php foreach ($menus as $menu): ?>
                <a href="<?php echo $pagePrefix; ?>?do=<?php echo $menu['do']; ?>" class="<?php echo $currentDo === $menu['do'] ? 'active' : ''; ?>"><?php echo $menu['name']; ?></a>
            <?php endforeach; ?>
        </nav>
    </div>
    
    <script src="./inc/pubs.js?v=<?php echo VERSION; ?>"></script>
    <script>
        // 设置全局变量
        window.pageSize = <?php echo PAGE_SIZE; ?>;
        window.autoRefresh = <?php echo AUTO_REFRESH; ?>;
    </script>